package com.fmy.security.service.defult;

import com.fmy.security.cache.Token;
import com.fmy.security.config.TokenProperties;
import com.fmy.security.service.TokenGenerate;
import org.springframework.security.core.Authentication;

import java.util.UUID;

/**
 * @author Mr.fmy
 * @version 1.0.0
 * @ClassName TokenGenerateDefult
 * @Description TODO
 * @createTime 2019/9/6 15:14
 */
public class TokenGenerateDefult implements TokenGenerate {
    @Override
    public Token generate(Authentication authentication, String loginType, long expireTime) {
        Token token = new Token();
        token.setLoginType(loginType);
        token.setAuthentication(authentication);
        token.setUsername(authentication.getName());
        token.setToken(UUID.randomUUID().toString());
        token.setExpireTime(expireTime);
        return token;
    }
}
